//
//  AppDelegate+NotificationCenter.m
//  CreditManger
//
//  Created by chaiyanan on 15/11/5.
//  Copyright © 2015年 jinxin. All rights reserved.
//

#import "AppDelegate+NotificationCenter.h"
#import "CMLoginManager.h"

@implementation AppDelegate (NotificationCenter)

- (void)notifyApplication:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
    [self setupNotifiers];
}

// 监听系统生命周期回调，以便将需要的事件传给SDK
- (void)setupNotifiers{
    [[NSNotificationCenter defaultCenter] addObserver:self
                                             selector:@selector(appDidEnterBackgroundNotif:)
                                                 name:UIApplicationDidEnterBackgroundNotification
                                               object:nil];
    
    
    [[NSNotificationCenter defaultCenter] addObserver:self
                                             selector:@selector(appWillEnterForeground:)
                                                 name:UIApplicationWillEnterForegroundNotification
                                               object:nil];
    
    
    [[NSNotificationCenter defaultCenter] addObserver:self
                                             selector:@selector(appDidFinishLaunching:)
                                                 name:UIApplicationDidFinishLaunchingNotification
                                               object:nil];
    
    
    [[NSNotificationCenter defaultCenter] addObserver:self
                                             selector:@selector(appDidBecomeActiveNotif:)
                                                 name:UIApplicationDidBecomeActiveNotification
                                               object:nil];
    
    [[NSNotificationCenter defaultCenter] addObserver:self
                                             selector:@selector(appWillResignActiveNotif:)
                                                 name:UIApplicationWillResignActiveNotification
                                               object:nil];
    
    [[NSNotificationCenter defaultCenter] addObserver:self
                                             selector:@selector(appDidReceiveMemoryWarning:)
                                                 name:UIApplicationDidReceiveMemoryWarningNotification
                                               object:nil];
    
    [[NSNotificationCenter defaultCenter] addObserver:self
                                             selector:@selector(appWillTerminateNotif:)
                                                 name:UIApplicationWillTerminateNotification
                                               object:nil];
    
    [[NSNotificationCenter defaultCenter] addObserver:self
                                             selector:@selector(appProtectedDataWillBecomeUnavailableNotif:)
                                                 name:UIApplicationProtectedDataWillBecomeUnavailable
                                               object:nil];
    
    [[NSNotificationCenter defaultCenter] addObserver:self
                                             selector:@selector(appProtectedDataDidBecomeAvailableNotif:)
                                                 name:UIApplicationProtectedDataDidBecomeAvailable
                                               object:nil];
    
    [[NSNotificationCenter defaultCenter] addObserver:self
                                             selector:@selector(appLoginDidQuitoutNotif:)
                                                 name:Notification_LoginDismiss
                                               object:nil];
}

#pragma mark - notifiers

- (void)appDidEnterBackgroundNotif:(NSNotification*)notif
{
    
}

- (void)appWillEnterForeground:(NSNotification*)notif
{
    
}

- (void)appDidFinishLaunching:(NSNotification*)notif
{
    
}

- (void)appDidBecomeActiveNotif:(NSNotification*)notif
{
    
}

- (void)appWillResignActiveNotif:(NSNotification*)notif
{
    
}

- (void)appDidReceiveMemoryWarning:(NSNotification*)notif
{
    
}

- (void)appWillTerminateNotif:(NSNotification*)notif
{
    
}

- (void)appProtectedDataWillBecomeUnavailableNotif:(NSNotification*)notif
{
    
}

- (void)appProtectedDataDidBecomeAvailableNotif:(NSNotification*)notif
{
    
}

- (void)appLoginDidQuitoutNotif:(NSNotification*)notif
{
    [CMLoginManager didLoginOut];
}


@end
